package com.kehutong.admin.entity;

import org.coraframework.bean.valid.CheckField;
import org.coraframework.orm.Entity;
import org.coraframework.orm.annotation.Column;
import org.coraframework.orm.annotation.Table;
import org.coraframework.orm.annotation.UnSave;

import java.util.List;

/**
 * 业务标签
 * 不同业务模块保存后会打上相关标签
 */
@Table(value="t_business_tag", comment="业务标签")
public class BusinessTag extends Entity{

	private static final long serialVersionUID = 4177501639936105917L;

	protected BusinessTag(String id) {
        super(id);
    }

    @CheckField("上级标签不能为空")
    @Column(length = 64, comment = "上级标签")
    private String pid;

	@UnSave
    private String pname;

    @CheckField("名称不能为空")
	@Column(comment = "标签名称")
    private String  name;

    @Column(comment = "标签描述")
    private String desc;
	
	@Column(comment = "是否标签组")
	private boolean group;

    @Column(comment = "状态：0禁用，1启用")
    private boolean status;


    @Column(comment = "使用数量")
    private long useCount;


    @Column(comment = "排序")
    private long sort;


    @Column(comment = "逻辑删除")
    private boolean deleted;

    @Column(comment="操作人")
    private String createBy;

    @Column(comment = "操作人名字")
    private String createName;

    @UnSave
    private List<BusinessTag> childList;

    public String getPid() {
        return pid;
    }

    public void setPid(String pid) {
        this.pid = pid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public boolean isGroup() {
        return group;
    }

    public void setGroup(boolean group) {
        this.group = group;
    }

    public boolean isDeleted() {
        return deleted;
    }

    public void setDeleted(boolean deleted) {
        this.deleted = deleted;
    }

    public String getCreateBy() {
        return createBy;
    }

    public void setCreateBy(String createBy) {
        this.createBy = createBy;
    }

    public String getCreateName() {
        return createName;
    }

    public void setCreateName(String createName) {
        this.createName = createName;
    }

    public List<BusinessTag> getChildList() {
        return childList;
    }

    public void setChildList(List<BusinessTag> childList) {
        this.childList = childList;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        if (!super.equals(o)) return false;

        BusinessTag businessTag = (BusinessTag) o;

        if (group != businessTag.group) return false;
        return pid.equals(businessTag.pid);
    }

    @Override
    public int hashCode() {
        int result = super.hashCode();
        result = 31 * result + pid.hashCode();
        result = 31 * result + name.hashCode();
        result = 31 * result + (group ? 1 : 0);
        return result;
    }

    public String getPname() {
        return pname;
    }

    public void setPname(String pname) {
        this.pname = pname;
    }


    public boolean isStatus() {
        return status;
    }

    public void setStatus(boolean status) {
        this.status = status;
    }

    public long getUseCount() {
        return useCount;
    }

    public void setUseCount(long useCount) {
        this.useCount = useCount;
    }

    public long getSort() {
        return sort;
    }

    public void setSort(long sort) {
        this.sort = sort;
    }
}